<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PHP Const</title>
    <style>
        tr.table-header {
            text-align: center;
        }
    </style>
</head>
<body>

<?php
/**
 * Created by PhpStorm.
 * User: aron
 * Date: 2019/5/6
 * Time: 9:28 AM
 */

define("USER_NAME", "root");
define("USER_PASS", "root");

echo "user name = " . USER_NAME . "<br />\r\n";

// PHP系统中的内置常量
$systemConsts = array(
    "PHP_OS" => PHP_OS,
    "PHP_VERSION" => PHP_VERSION,
    "DIRECTORY_SEPARATOR" => DIRECTORY_SEPARATOR,
    "TRUE" => TRUE,
    "FALSE" => FALSE,
    "NULL" => NULL,
    "PATH_SEPARATOR" => PATH_SEPARATOR,
    "E_ERROR" => E_ERROR,
    "E_NOTICE" => E_NOTICE,
    "E_PARSE" => E_PARSE,
    "E_WARNING" => E_WARNING,
    "M_PI" => M_PI,
    "M_PI_2" => M_PI_2,
);
echo "<table border='1px solid gray'>";

echo "<tr class='table-header'>";
echo "<td colspan='2'>";
echo "PHP内置的常量";
echo "</td>";
echo "</tr>";

foreach ($systemConsts as $constName => $constValue) {
    echo "<tr>";
    echo "<td>";
    echo $constName;
    echo "</td>";
    echo "<td>";
    echo $constValue;
    echo "</td>";
    echo "</tr>";

}

echo "</table>";



class MagicConst {
    function printMagicConst() {
        // PHP魔术常量
        echo "<br />\r\n";
        $magicConsts = array(
            "__FILE__" => __FILE__,
            "__CLASS__" => __CLASS__,
            "__FUNCTION__" => __FUNCTION__,
            "__METHOD__" => __METHOD__,
            "__LINE__" => __LINE__,
        );
        echo "<table border='1px solid gray'>";

        echo "<tr class='table-header'>";
        echo "<td colspan='2'>";
        echo "PHP魔术常量";
        echo "</td>";
        echo "</tr>";

        foreach ($magicConsts as $constName => $constValue) {
            echo "<tr>";
            echo "<td>";
            echo $constName;
            echo "</td>";
            echo "<td>";
            echo $constValue;
            echo "</td>";
            echo "</tr>";

        }

        echo "</table>";
    }
}

$magicConsts = new MagicConst();
$magicConsts->printMagicConst();

?>

</body>
</html>
